<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script type="text/javascript">
        let user = {
            name: "杨同宇",
            sex: "男",
            age: 15
        };
        //将js对象转换为json对象；
        let json = JSON.stringify(user);
        console.log(json);
        // '{"name":"杨同宇","sex":"男","age":15}'
        //将json对象转换为js对象
        let obj = JSON.parse(json);
        console.log(obj);
    </script>
</head>
<body>

</body>
</html>